package org.jsola.hr.helper;

import org.jsola.common.ClassKit;
import org.jsola.common.SafeKit;
import org.jsola.hr.constant.EmpSocStatus;
import org.jsola.hr.constant.SocBusinessType;
import org.jsola.hr.constant.SocPayCostType;
import org.jsola.hr.dto.EmpSocInfoAddBatchDTO;
import org.jsola.hr.dto.EmpSocInfoAddDTO;
import org.jsola.hr.dto.EmpSocInfoUpdateDTO;
import org.jsola.hr.entity.EmpSocInfoDO;
import org.jsola.hr.query.EmpSocInfoQuery;
import org.jsola.hr.service.IEmpSocInfoService;
import org.jsola.hr.vo.EmpSocInfoResultVO;
import org.jsola.hr.vo.EmpSocInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 员工参保信息表
 *
 * @author zhr
 */
@Component
public class EmpSocInfoTestHelper extends BaseTestHelper {
    
    @Autowired
    private IEmpSocInfoService empSocInfoService;

    /**
     * 生成add测试数据
     * @return EmpSocInfoAddDTO
     */
    public EmpSocInfoAddDTO getEmpSocInfoAddDTO(){
        EmpSocInfoAddDTO empSocInfoAddDTO = new EmpSocInfoAddDTO();
        empSocInfoAddDTO.setPayCostType(SocPayCostType.NORMAL_PAY_COST.getValue());
        empSocInfoAddDTO.setPlanFlag(SafeKit.getBoolean(getRandomValue("tinyint",4)));
        empSocInfoAddDTO.setBusinessType(SocBusinessType.OPEN_ACCOUNT.getValue());
        empSocInfoAddDTO.setSupplementType(getRandomValue("varchar",4));
        empSocInfoAddDTO.setEmpId(getRandomValue("varchar",32));
        empSocInfoAddDTO.setProgId(getRandomValue("varchar",32));
        empSocInfoAddDTO.setMonthId(getRandomValue("varchar",32));
        empSocInfoAddDTO.setYear(getRandomValue("varchar",32));
        empSocInfoAddDTO.setMonth(getRandomValue("varchar",32));
        empSocInfoAddDTO.setPersonalSocAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocInfoAddDTO.setPersonalPfAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocInfoAddDTO.setCompanySocAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocInfoAddDTO.setCompanyPfAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocInfoAddDTO.setServiceCost(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocInfoAddDTO.setWhetherLeave(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        empSocInfoAddDTO.setSocialSecurityFine(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocInfoAddDTO.setAccumulationFundFine(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocInfoAddDTO.setCompanyId(getRandomValue("varchar",32));
        empSocInfoAddDTO.setGroupId(getRandomValue("varchar",50));
        empSocInfoAddDTO.setEmpSocStatus(EmpSocStatus.NOT_SOC.getValue());
        empSocInfoAddDTO.setEmpPfStatus(SafeKit.getInteger(getRandomValue("int",2)));
        return empSocInfoAddDTO;
    }


    /**
     * 生成update测试数据
     * @return EmpSocInfoUpdateDTO
     */
    public EmpSocInfoUpdateDTO getEmpSocInfoUpdateDTO(EmpSocInfoVO empSocInfoVO){
        return empSocInfoService.selectDOById(empSocInfoVO.getId(), SITE_ID).to(EmpSocInfoUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return EmpSocInfoQuery
     */
    public EmpSocInfoQuery getEmpSocInfoQuery() {
        EmpSocInfoQuery empSocInfoQuery = new EmpSocInfoQuery();
        List<EmpSocInfoDO> empSocInfoDOList = empSocInfoService.list(new EmpSocInfoDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(empSocInfoDOList)) {
            EmpSocInfoDO empSocInfoDO = empSocInfoDOList.get(0);
            empSocInfoQuery = empSocInfoDO.to(EmpSocInfoQuery.class);
        }
        return empSocInfoQuery;
    }


}

